package com.example.campusrear.Controller;

import com.example.campusrear.Service.ClassService;
import com.example.campusrear.Utils.R;
import com.example.campusrear.entity.Class;
import com.example.campusrear.entity.Student;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/class")
public class ClassController {
    @Resource
    private ClassService classService;
    @PostMapping("/save")
    public  R<String> save(@RequestBody Class sClass){
        classService.save(sClass);
        return R.success("添加成功");
    }

    @PostMapping("/upload")
    public R<String> upload(@RequestBody Class sClass){
        classService.updateById(sClass);
        return R.success("修改成功");
    }
    @DeleteMapping("/delete/{cId}")
    public R<String> delete(@PathVariable Long cId){
        classService.removeById(cId);
        return R.success("删除成功");
    }

    @GetMapping("/queryClass")
    public R<Class> queryClass(Long cId){
        Class aClass = classService.getById(cId);
        return R.success(aClass);
    }

    @GetMapping("/allClass")
    public R<List<Class>> allClass(){
        List<Class> list = classService.list();
        return R.success(list);
    }

}
